Skip to content

fix(android_alarm_manger_plus): Periodic alarm becomes inexact after some time#496

Merged
miquelbeltran merged 5 commits intofluttercommunity:mainfrom
vbuberen:fix/exact_alarm
Oct 5, 2021
Merged

fix(android_alarm_manger_plus): Periodic alarm becomes inexact after some time#496
miquelbeltran merged 5 commits intofluttercommunity:mainfrom
vbuberen:fix/exact_alarm

Conversation

@vbuberen
Copy link
Copy Markdown
Collaborator

@vbuberen vbuberen commented Oct 4, 2021

Description

This PR should address issue with periodic alarms which have exact=true losing accuracy after some time. I believe it is something connected with power optimisations done by different Android versions.
While looking through plugin code I saw that periodic is inconsistent with oneShot calls, since in oneShot users have allowWhileIdle parameter which should call setAndAllowWhileIdle function from AlarmManagerCompat class instead of just set. It means that even with exact set to true periodic alarms were never set to allow while the phone is in idle, which might be the case reported in #487.

It seems that the issue reporter uses Samsung and as an owner of Samsung device as well I know that their implementation of power management is quite aggressive and suspends apps, which aren't used for some days.

Note that this PR is based on #494, because otherwise I couldn't build the example app.

Related Issues

This PR potentially closes #487

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]).
This will ensure a smooth and quick review process. Updating the pubspec.yaml and changelogs is not required.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (flutter analyze) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (please indicate a breaking change in CHANGELOG.md and increment major revision).
  • No, this is not a breaking change.

@mhadaily mhadaily added Hacktoberfest Issues taking part in Hacktoberfest hacktoberfest-accepted labels Oct 5, 2021
@mhadaily mhadaily requested a review from miquelbeltran October 5, 2021 01:32
Copy link
Copy Markdown
Member

@miquelbeltran miquelbeltran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, exposing more params is always good!

Can you fix the merge conflict? Then we will proceed with the merge and release.

Thank you!

@miquelbeltran
Copy link
Copy Markdown
Member

I fixed the merge conflict, will merge once CI is done.

@vbuberen
Copy link
Copy Markdown
Collaborator Author

vbuberen commented Oct 5, 2021

Sure, I can fix. You were pretty quick though 😀

@miquelbeltran miquelbeltran merged commit e51b005 into fluttercommunity:main Oct 5, 2021
@miquelbeltran
Copy link
Copy Markdown
Member

merged and released

@vbuberen vbuberen deleted the fix/exact_alarm branch October 5, 2021 10:11
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Feb 5, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Hacktoberfest Issues taking part in Hacktoberfest hacktoberfest-accepted

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Alarm manager is inexact in periodic method (exact= true is not working).

3 participants